@extends('admin.app')

@section('breadcrumb')
  <div class="bg-light lter b-b wrapper-md">
    <ol class="breadcrumb bg-light lter m-n no-padder">
      <li><a href="{{admin_action('HomeController@index')}}">主页</a></li>
      <li><a href="{{admin_action('Web\ProfitsController@index')}}">分润规则</a></li>
      <li class="active">编辑分润规则</li>
    </ol>
  </div>
@endsection

@section('content')
  <div class="panel panel-default">
    <div class="panel-heading font-bold">
      分润规则信息
    </div>
    <div class="panel-body">
      <form class="form-horizontal form-validation" action="{{ admin_action('Web\ProfitsController@update',[$profit]) }}" method="post">
        {{ csrf_field() }}
        {{ method_field('PUT') }}
        <div class="form-group">
          <label class="col-lg-2 control-label">模板名称*</label>
          <div class="col-lg-10">
            <input type="text" class="form-control" name="name" value="{{$profit->name}}" placeholder="请输入模板名称" data-rule-required="true" data-rule-maxlength="100">
          </div>
        </div>
        <div class="line line-dashed b-b line-lg"></div>
        @foreach ($stages as $stage)
          <div class="form-group">
            <label for="inputPosition" class="col-sm-2 control-label">{{$stage->name}}*</label>
            <div class="col-sm-12">
              <div class="form-group">
                <label for="inputPosition" class="col-sm-2 control-label"></label>
                <div  class="col-sm-7">
                  @foreach ($profit_roles as $profit_role)
                    @if($stage->code==$profit_role->stage)
                      <div class="form-group">
                        <label for="inputPosition" class="col-sm-2 control-label">{{$profit_role->role()->name}} </label>
                        <div class="col-sm-3">
                          <input type="text" class="form-control" name="{{$stage->code.'-'.$profit_role->role}}" value="{{$profit_role->scale}}" {{in_array($profit_role->role,$arr[$stage->code])?'':'readonly'}}/>
                        </div>
                        <div class="col-sm-3 ">%</div>
                      </div>
                    @endif
                  @endforeach
                </div>
              </div>
            </div>
          </div>
        @endforeach

        <div class="line line-dashed b-b line-lg"></div>
        <div class="form-group">
          <label class="col-lg-2 control-label">分润方式*</label>
          <div class="col-lg-10">
            <select name="mode" class="form-control select2">
              <option value>-----请选择分润方式-----</option>
              @foreach ($modes as $mode)
                <option value="{{$mode->code}}" {{$profit->mode==$mode->code?'selected':''}}>{{$mode->name}}</option>
              @endforeach
            </select>
          </div>
        </div>
        <div class="line line-dashed b-b line-lg"></div>
        <div class="form-group">
          <div class="col-lg-4 col-lg-offset-2">
            <a href="{{ admin_action('Web\ProfitsController@index') }}" class="btn btn-default">返&nbsp;回</a>
            <button type="submit" class="btn btn-primary">保&nbsp;存</button>
          </div>
        </div>
      </form>
    </div>
  </div>
@endsection

